// 服务器接口返回的通用数据类型
export interface ResponseData {
  code: number
  message: string
  ok: boolean
}

// SPU数据的ts类型:需要修改
export interface SpuData {
  category3Id: number
  id?: number
  spuName: string
  tmId: number | string
  description: string
  spuImageList: null | SpuImg[]
  spuSaleAttrList: null | SpuSaleValue[]
}

// 数组：元素都是已有SPU数据类型
export type Records = SpuData[]

// 定义获取已有的SPU接口返回的数据ts类型
export interface HasSpuResponseData extends ResponseData {
  data: {
    records: Records
    total: number
    size: number
    current: number
    searchCount: boolean
    pages: number
  }
}

// 定义所有SPU品牌数据的ts类型
export interface TradeMarkData {
  id: number
  tmName: string
  logoUrl: string
}

export type TradeMarkList = TradeMarkData[]

// 定义获取所有SPU品牌接口返回的数据ts类型
export interface AllTradeMarkResponseData extends ResponseData {
  data: TradeMarkList
}

// 定义商品图片对象的ts类型
export interface SpuImg {
  id?: number
  imgName?: string
  imgUrl?: string
  spuId?: number
  name?: string
  url?: string
}

// 定义获取某个SPU的图片接口返回的数据ts类型
export interface SpuImgResponseData extends ResponseData {
  data: SpuImg[]
}

// 某个SPU下对应的已有销售属性值列表
export interface SpuSaleAttrValue {
  id?: number
  saleAttrValueName: string
  baseSaleAttrId: number | string
  spuId?: number
}

// 某个SPU下对应的销售属性对象
export interface SpuSaleValue {
  id?: number
  baseSaleAttrId: number
  saleAttrName: string
  saleAttrvalue?: string
  spuId?: number
  spuSaleAttrValueList?: SpuSaleAttrValue[]
  flag?: boolean
}

// 销售属性接口返回的ts数据类型
export interface SpuSaleResponseData extends ResponseData {
  data: SpuSaleValue[]
}

// 获取当前系统所有的销售列表
export interface BaseSaleAttr {
  id: number
  name: string
}

// 获取销售列表接口返回的ts类型
export interface BaseSaleAttrResponseData extends ResponseData {
  data: BaseSaleAttr[]
}

export interface Attr {
  attrId: number //平台属性的ID
  valueId: number //属性值的ID
}

export interface saleArr {
  saleAttrId: number //属性ID
  saleAttrValueId: number //属性值的ID
}

export interface skuImgArr {
  id: number
  skuId: number
  imgName: string
  imgUrl: string
  spuImgId: number
  isDefault: string
}

// 保存SKU的ts数据类型
export interface SkuData {
  id: number
  spuID: number
  category3Id: number
  tmId: number
  skuName: string
  weight: number
  price: number
  skuDesc: string
  skuDefaultImg: string
  isSale: number
  skuAttrValueList?: Attr[]
  skuSaleAttrValueList?: saleArr[]
  skuImageList?: skuImgArr[]
}
